﻿using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Miao
{
    public static class DefOfHelper
    {
        //public static void RebindAllDefOfs(bool earlyTryMode)
        //{
        //    foreach (Type item in MiaoTypes.AllTypesWithAttribute<DefOf>())
        //    {
        //        BindDefsFor(item);
        //    }
        //}

        //private static void BindDefsFor(Type type)
        //{
        //    FieldInfo[] fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
        //    foreach (FieldInfo fieldInfo in fields)
        //    {
        //        Type fieldType = fieldInfo.FieldType;
        //        if (!typeof(Def).IsAssignableFrom(fieldType))
        //        {
        //            Log.Error(string.Concat(fieldType, " is not a Def."));
        //            continue;
        //        }
        //        MayRequireAttribute mayRequireAttribute = fieldInfo.TryGetAttribute<MayRequireAttribute>();
        //        bool flag = (mayRequireAttribute == null || ModsConfig.IsActive(mayRequireAttribute.modId)) && !earlyTry;
        //        string text = fieldInfo.Name;
        //        DefAliasAttribute defAliasAttribute = fieldInfo.TryGetAttribute<DefAliasAttribute>();
        //        if (defAliasAttribute != null)
        //        {
        //            text = defAliasAttribute.defName;
        //        }
        //        if (fieldType == typeof(SoundDef))
        //        {
        //            SoundDef soundDef = SoundDef.Named(text);
        //            if (soundDef.isUndefined && flag)
        //            {
        //                Log.Error("Could not find SoundDef named " + text);
        //            }
        //            fieldInfo.SetValue(null, soundDef);
        //        }
        //        else
        //        {
        //            Def def = GenDefDatabase.GetDef(fieldType, text, flag);
        //            fieldInfo.SetValue(null, def);
        //        }
        //    }
        //}
    }
}
